home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Keyboard / Keyboard Messages / SpecialKeyMessage.h < prev    next >
Encoding:
Text File  |  1997-06-28  |  644 b   |  37 lines  |  [TEXT/CWIE]

  1. // SpecialKeyMessage.h
  2.  
  3. #ifndef SpecialKeyMessage_h
  4. #define SpecialKeyMessage_h
  5.  
  6. #ifndef KeyMessage_h
  7. #include "KeyMessage.h"
  8. #endif
  9. #ifndef Commander_h
  10. #include "Commander.h"
  11. #endif
  12.  
  13. template < class TheProtocol >
  14. class SpecialKeyMessage: public KeyMessage
  15.   {
  16.     typedef TheProtocol Protocol;
  17.     typedef void (Protocol::*MethodType)();
  18.     
  19.     private:
  20.         MethodType method;
  21.         
  22.     public:
  23.         SpecialKeyMessage( MethodType theMethod )
  24.           : method( theMethod )
  25.           {}
  26.         
  27.         MethodType Method() const        { return method; }
  28.         
  29.         virtual void Send() const
  30.           {
  31.             if ( !Commander<Protocol>::Null() )
  32.                 ((*Commander<Protocol>()).*method)();
  33.           }
  34.   };
  35.  
  36. #endif
  37.